/*******************************************************************************
 * Copyright 2011 Andrea Guitto
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.andreaguitto.mobile.android.framework.base.object.activity;

import android.os.Bundle;
import android.widget.ImageView;

import com.andreaguitto.mobile.android.framework.base.interfaces.AGSplashScreenInterface;
import com.andreaguitto.mobile.android.framework.base.workers.AGSimpleSplashWorker;
import com.andreaguitto.mobile.android.framework.base.workers.AGSplashWorker;

public abstract class AGMainActivity extends AGActivity implements AGSplashScreenInterface {
    
    private int splashVisibility;
    private long splashDelay = 5000; 
    
    private AGSplashWorker splashWorker = new AGSimpleSplashWorker(this);
    
    @Override
    protected void onCreate(Bundle savedInstanceState){
    	super.onCreate(savedInstanceState);
    }
    
    @Override
    protected void onStart(){
		super.onStart();
		if(getSplashVisibility()== VISIBILITY_ON_START)			
			splashWorker.showSplashScreen(splashDelay);
	}
    
    @Override
    protected void onResume(){
		super.onResume();
		if(getSplashVisibility()== VISIBILITY_ON_RESUME){
			splashWorker.showSplashScreen(splashDelay);
		}
	}   
    
    @Override
    public void onBeforeShowSplash(){
    	splashWorker.onBeforeShowSplash();
    }
    
    @Override
    public void onShowSplash(){
    	splashWorker.onShowSplash();
    }
    
    @Override   
    public void onHideSplash(){
    	splashWorker.onHideSplash();
    }
    
    @Override
    public void onAfterSplashHidden(){ 	
    	splashWorker.onAfterSplashHidden();
    }    
    
	public ImageView getSplashImage() {	return ((AGSimpleSplashWorker) splashWorker).getSplashImage();	}
	public void setSplashImage(ImageView splashImage) {	((AGSimpleSplashWorker) splashWorker).setSplashImage(splashImage);	}

	public void setSplashVisibility(int splashVisibility) {		this.splashVisibility = splashVisibility;	}
	public int getSplashVisibility() {	return splashVisibility;	}

	public long getSplashDelay() {	return splashDelay;	}
	public void setSplashDelay(long splashDelay) {	this.splashDelay = splashDelay;	};
	
}
